package org.graduation.project.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.graduation.model.common.project.Task;
import org.graduation.model.common.user.User;
import org.graduation.project.mapper.MybatisPlusWrapperFactory;
import org.graduation.project.mapper.TaskAndUserMapper;
import org.graduation.project.mapper.TaskMapper;
import org.graduation.project.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements TaskService {
    @Autowired
    private TaskMapper taskMapper;
    @Autowired
    private TaskAndUserMapper taskAndUserMapper;
    @Override
    public boolean realDeleteTask(Task task) {
        taskAndUserMapper.delete(MybatisPlusWrapperFactory.deleteTaskAndUser(task));
        return taskMapper.deleteById(task.getTaskId()) > 0;
    }

    @Override
    public List<Task> getAllAlarmTask(User user) {
        return taskMapper.getAllAlarmTask(user);
    }
}
